*** Replication file June 2018 for R&R with JHR
use "/Users/OlsonLounsberyM/Documents/JHR OSV FMI article/June data 2018/OLP Goverment Replication 7 removed 20089.dta"
** Years 2007, 8, 9 removed
gen FMIG = hostile+supportive+neutral
tab FMIG
recode FMIG 2=1 1=1 0=0 .=.
label variable FMIG "Foreign Military Intervention in GOSV"
tab FMIG

** Descriptives GOSV
sum new_gov_best, detail
sum new_gov_best if rwanda94==0, detail
tab supportive
tab hostile
tab neutral
tab dichGOSV

rename new_gov_best GOSV
label variable GOSV "Government One Sided Violence"

** Descriptives for OSV
use "/Users/OlsonLounsberyM/Documents/JHR OSV FMI article/June data 2018/Merged for ROSV and GOSV.dta", clear
gen OSV=ROSV+GOSV
sum OSV, detail
gen dichOSV = OSV
recode dichOSV .=. 0=0 *=1
label variable dichOSV "Dichotomous indicator of OSV"
tab dichOSV
sum OSV if rwanda94==0, detail
tab dichOSV if rwanda94==0

drop if ccode==.
tab dichOSV, mi

save "/Users/OlsonLounsberyM/Documents/JHR OSV FMI article/June data 2018/Merged for ROSV and GOSV.dta"
tab dichOSV, mi
drop if ccode==.
tab dichOSV, mi
tab dichOSV if rwanda94==0, mi

**Descriptives ROSV

use "/Users/OlsonLounsberyM/Documents/ISA South 2015/ISA South datawork/Revised data for pub/November 2016/OLP Rebel violence replication data5.dta"
drop if year>2006
save "/Users/OlsonLounsberyM/Documents/JHR OSV FMI article/June data 2018/OLP Rebel violence replication data6.dta"

gen FMI = hostile+supportive+neutral
tab FMI
recode FMI 2=1 1=1 0=0 .=.
tab FMI
logit FMI rebbest2010
logit supportive rebbest2010
label variable FMI "Foreign Military Intervention"

rename rebbest2010 ROSV
label variable ROSV "Rebel One Sided Violence"

*** Examining OSV as a predictor of FMI - H1
**generating laggedOSV
use "/Users/OlsonLounsberyM/Documents/JHR OSV FMI article/June data 2018/Merged for ROSV and GOSV.dta"
tsset ccode year
gen laggedOSV=l1.OSV
logit OSV FMI laggedOSV, cluster(ccode)
regress OSV laggedOSV
gen laggedOSVmis=laggedOSV
recode laggedOSVmis .=0
logit OSV FMI laggedOSVmis, cluster(ccode)
regress OSV laggedOSVmis

*modelbuilding
logit FMIG OSV laggedFMI if rwanda94==0, cluster(ccode)
logit FMIG lntotbdeaths laggedFMI if rwanda94==0, cluster(ccode)
logit FMIG lnRefchg laggedFMI if rwanda94==0, cluster(ccode)
logit FMIG totalborder laggedFMI if rwanda94==0, cluster(ccode)
logit FMIG stronger laggedFMI if rwanda94==0, cluster(ccode)
logit FMIG parity laggedFMI if rwanda94==0, cluster(ccode)
logit FMIG maxmult_reb laggedFMI if rwanda94==0, cluster(ccode)
logit FMIG Alliance laggedFMI if rwanda94==0, cluster(ccode)
logit FMIG new_lnlagtpop laggedFMI if rwanda94==0, cluster(ccode)
logit FMIG new_laggdp laggedFMI if rwanda94==0, cluster(ccode)
logit FMIG democracy laggedFMI if rwanda94==0, cluster(ccode)

gen strongerpar = stronger + parity
label variable strongerpar "Rebels at least at parity"

logit FMIG OSV lntotbdeaths lnRefchg totalborder strongerpar maxmult_reb Alliance democracy laggedFMI if rwanda94==0, cluster(ccode)
vif, uncentered
logit FMIG OSV lntotbdeaths lnRefchg totalborder strongerpar maxmult_reb Alliance democracy laggedFMI if rwanda94==0, cluster(ccode)


*collinearity
* new_lnlagtpop with new_laggdp, removed from models
* lnRefchg is problematic with lntobdeaths and totalborder
*Model 1 predicting FMI
logit FMIG lagOSV lntotbdeaths totalborder strongerpar maxmult_reb Alliance laggedFMI if rwanda94==0, cluster(ccode)
*Model 2 predicting FMI with refugees
logit FMIG lagOSV lnRefchg strongerpar maxmult_reb Alliance laggedFMI if rwanda94==0, cluster(ccode)

** Robustness checks
*Model 1 and 2
logit FMIG lagOSV lntotbdeaths totalborder strongerpar maxmult_reb Alliance democracy laggedFMI if rwanda94==0, cluster(ccode)
logit FMIG lagOSV lntotbdeaths lnRefchg totalborder strongerpar maxmult_reb Alliance democracy laggedFMI if rwanda94==0, cluster(ccode)
vif, uncentered

*** Predicting HFMI - H2
use "/Users/OlsonLounsberyM/Documents/JHR OSV FMI article/June data 2018/OLP Goverment Replication 7 removed 20089.dta"

logit hostile lagGOSV lntotbdeaths totalborder strongerpar maxmult_reb Alliance democracy lhostile if rwanda94==0, cluster(ccode)
vif, uncentered
collin lagGOSV lntotbdeaths totalborder strongerpar maxmult_reb Alliance democracy lhostile if rwanda94==0
logit hostile GOSV lnRefchg totalborder strongerpar maxmult_reb Alliance democracy lhostile if rwanda94==0, cluster(ccode)
vif, uncentered GOSV lnRefchg totalborder strongerpar maxmult_reb Alliance democracy lhostile
collin GOSV lnRefchg totalborder strongerpar maxmult_reb Alliance democracy lhostile if rwanda94==0

*Model 3
logit hostile lagGOSV lntotbdeaths totalborder strongerpar maxmult_reb Alliance democracy lhostile, cluster(ccode)
*Model 4
logit hostile lagGOSV lnRefchg totalborder strongerpar maxmult_reb Alliance democracy lhostile, cluster(ccode)

*** Predicting SFMI - H3
use "/Users/OlsonLounsberyM/Documents/JHR OSV FMI article/June data 2018/OLP Rebel violence replication data6.dta"
rename lagreb2010 lagROSV
collin lagROSV lnbdbest totalborder strongerpar multreb Alliance democracy lsupportive
collin lagROSV lnRefchg strongerpar multreb Alliance democracy lsupportive

*Model 5
logit supportive lagROSV lnbdbest totalborder strongerpar multreb Alliance democracy lsupportive, cluster(conflictid)
fitstat, save
*Model 6
logit supportive lagROSV lnRefchg strongerpar multreb Alliance democracy lsupportive, cluster(conflictid)
fitstat, diff force
* Model 6 very strong support

*** Predicting NFMI - H4
use "/Users/OlsonLounsberyM/Documents/JHR OSV FMI article/June data 2018/OLP Goverment Replication 7 removed 20089.dta"
*Model 7
logit neutral lagGOSV totalborder strongerpar Alliance lneutral if rwanda94==0, cluster(ccode)
vif, uncentered
*Model8
logit neutral lagGOSV lnRefchg totalborder strongerpar Alliance lneutral if rwanda94==0, cluster(ccode)
collin lagGOSV lnRefchg totalborder strongerpar Alliance lneutral if rwanda94==0
** condition number 11.9489

logit neutral lagGOSV totalborder strongerpar Alliance lneutral if rwanda94==0, cluster(ccode)
fitstat, save
logit neutral lagGOSV lnRefchg totalborder strongerpar Alliance lneutral if rwanda94==0, cluster(ccode)
fitstat, diff force
* support for current model8

** Predicted Probabilities
use "/Users/OlsonLounsberyM/Documents/JHR OSV FMI article/June data 2018/OLP Goverment Replication 7 removed 20089.dta"
logit neutral lagGOSV lnRefchg totalborder i.strongerpar i.Alliance i.lneutral if rwanda94==0, cluster(ccode)
margins, dydx(*)
listcoef, help percent
mchange

*** Final Tables
use "/Users/OlsonLounsberyM/Documents/JHR OSV FMI article/June data 2018/Merged for ROSV and GOSV.dta"
quietly logit FMIG lagOSV lntotbdeaths totalborder strongerpar maxmult_reb Alliance democracy laggedFMI if rwanda94==0, cluster(ccode)
est store model1
quietly logit FMIG lagOSV lntotbdeaths lnRefchg totalborder strongerpar maxmult_reb Alliance democracy laggedFMI if rwanda94==0, cluster(ccode)
est store model2
use "/Users/OlsonLounsberyM/Documents/JHR OSV FMI article/June data 2018/OLP Goverment Replication 7 removed 20089.dta"
quietly logit hostile lagGOSV lntotbdeaths totalborder strongerpar maxmult_reb Alliance democracy lhostile, cluster(ccode)
est store model3
quietly logit hostile lagGOSV lnRefchg totalborder strongerpar maxmult_reb Alliance democracy lhostile, cluster(ccode)
est store model4
esttab model1 model2 model3 model4, se brackets l scalars("ll Log lik." "chi2 Chi-squared") star(+ 0.10 * 0.05 ** .01)
use "/Users/OlsonLounsberyM/Documents/JHR OSV FMI article/June data 2018/OLP Rebel violence replication data6.dta"
quietly logit supportive lagROSV lnbdbest totalborder strongerpar multreb Alliance democracy lsupportive, cluster(conflictid)
est store model5
quietly logit supportive lagROSV lnRefchg strongerpar multreb Alliance democracy lsupportive, cluster(conflictid)
est store model6
use "/Users/OlsonLounsberyM/Documents/JHR OSV FMI article/June data 2018/OLP Goverment Replication 7 removed 20089.dta"
quietly logit neutral lagGOSV totalborder strongerpar Alliance lneutral if rwanda94==0, cluster(ccode)
est store model7
quietly logit neutral lagGOSV lnRefchg totalborder strongerpar Alliance lneutral if rwanda94==0, cluster(ccode)
est store model8
esttab model5 model6 model7 model8, se brackets l scalars("ll Log lik." "chi2 Chi-squared") star(+ 0.10 * 0.05 ** .01)

*Produce model statistics
use "/Users/OlsonLounsberyM/Documents/JHR OSV FMI article/June data 2018/Merged for ROSV and GOSV.dta"
logit FMIG lagOSV lntotbdeaths totalborder strongerpar maxmult_reb Alliance democracy laggedFMI if rwanda94==0, cluster(ccode)
logit FMIG lagOSV lntotbdeaths lnRefchg totalborder strongerpar maxmult_reb Alliance democracy laggedFMI if rwanda94==0, cluster(ccode)

use "/Users/OlsonLounsberyM/Documents/JHR OSV FMI article/June data 2018/OLP Goverment Replication 7 removed 20089.dta"
logit hostile lagGOSV lntotbdeaths totalborder strongerpar maxmult_reb Alliance democracy lhostile, cluster(ccode)
logit hostile lagGOSV lnRefchg totalborder strongerpar maxmult_reb Alliance democracy lhostile, cluster(ccode)

use "/Users/OlsonLounsberyM/Documents/JHR OSV FMI article/June data 2018/OLP Rebel violence replication data6.dta"
logit supportive lagROSV lnbdbest totalborder strongerpar multreb Alliance democracy lsupportive, cluster(conflictid)
logit supportive lagROSV lnRefchg strongerpar multreb Alliance democracy lsupportive, cluster(conflictid)

use "/Users/OlsonLounsberyM/Documents/JHR OSV FMI article/June data 2018/OLP Goverment Replication 7 removed 20089.dta"
logit neutral lagGOSV totalborder strongerpar Alliance lneutral if rwanda94==0, cluster(ccode)
logit neutral lagGOSV lnRefchg totalborder strongerpar Alliance lneutral if rwanda94==0, cluster(ccode)



